
#ifndef __POLYHEDRONBUILDERPLUS_H__
#define __POLYHEDRONBUILDERPLUS_H__

#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Polyhedron_incremental_builder_3.h>

CGAL_BEGIN_NAMESPACE

/// This class modifies the original Polyhedron incremental builder class.
/// The new builder builds a polyhedron with its geometric information
/// independent of its topological information
template < class HalfedgeDS_>
class HDSplus_incremental_builder_3 : public Polyhedron_incremental_builder_3<HalfedgeDS_>{
public:
   typedef Polyhedron_incremental_builder_3<HalfedgeDS_> Parent;
public: 
   typedef HalfedgeDS_                    HDS; // internal  
   typedef typename HDS::Vertex           Vertex;      
   typedef typename HDS::Vertex_handle    Vertex_handle;
   typedef typename HDS::Halfedge_handle   Halfedge_handle;
   
   HDSplus_incremental_builder_3(HDS& h, bool verbose = false) : Parent(h, verbose){
        CGAL_assertion_code(Parent::check_protocoll = 0;)
   }
   
   Vertex_handle add_vertex(unsigned int id) {
      // adds p to the vertex list.
      CGAL_assertion( Parent::check_protocoll == 1);
      if ( Parent::hds.size_of_vertices() >= Parent::hds.capacity_of_vertices()) {
         Verbose_ostream verr( Parent::m_verbose);
         verr << " " << std::endl;
         verr << "CGAL::HDSplus_incremental_builder_3<HDS>::"
               << std::endl;
         verr << "add_vertex(): capacity error: more than " << Parent::new_vertices
               << " vertices added." << std::endl;
         Parent::m_error = true;
         return Vertex_handle();
      }
      HalfedgeDS_decorator<HDS> decorator(Parent::hds);
      Vertex vp(id);
      Vertex_handle v = decorator.vertices_push_back(vp);
      Parent::index_to_vertex_map.push_back(v);
      decorator.set_vertex_halfedge( v, Halfedge_handle());
      push_back_vertex_to_edge_map( Halfedge_handle());
      ++Parent::new_vertices;
      return v;
   }
};

CGAL_END_NAMESPACE

#endif
